<?php
namespace App\Http\Controllers\TextRecord;
use Illuminate\Http\Request;
use App\Http\Controllers\BaseApiController;
use App\Services\TextRecord\TextRecordService;


class TextRecordController extends BaseApiController
{
    private $service;

    public function __construct(TextRecordService $service)
    {
        //继承基类的构造方法
        parent::__construct();
        //依赖注入service
        $this->service = $service;
    }

    public function add(Request $request)
    {

        $rule = ['textre_scord' => 'required|integer|max:1000', 'ceshi_type' => 'required|integer|max:1000', 'text_id' => 'required|max:255'];
        if ($error = $this->validate($rule, $request)) {
            return $error;
        }
        $data = $request->all();
        return $this->service->add($data);
    }

    public function CheckOneByIDandChetype(Request $request)
    {
        $rule = ['ceshi_type' => 'required|integer|max:1000'];
        if ($error = $this->validate($rule, $request)) {
            return $error;
        }
        $data = $request->all();
        return $this->service->CheckOneByIDandChetype($data);
    }
}